package com.company.gas.service.impl;


import com.company.gas.mapper.MaterialMapper;
import com.company.gas.pojo.Material;
import com.company.gas.service.IMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * @author: Li Guangdi
 *
 */
@Service
public class MaterialServiceImpl implements IMaterialService {

    @Autowired
    private MaterialMapper materialMapper;


    @Override
    public List<Material> queryMaterialList() {
        List<Material> materialList = materialMapper.selectAll();
        for(Material material : materialList){
            System.out.println(material);
        }
        return materialList;
    }

    @Override
    public Material queryMaterialById(String matId) {
        Material material =materialMapper.queryMaterialById(matId);
        System.out.println(material);
        return material;
    }

    @Override
    public int addMaterial(String matId,String matName,Integer store,Integer available,Integer flag,String createBy,String modifyBy) {
        materialMapper.addMaterial(matId,matName,store,available,flag,createBy,modifyBy);
        return 1;
    }

    @Override
    public int updateMaterial(String matId,String matName,Integer store,Integer available,Integer flag,String modifyBy) {
        materialMapper.updateMaterial(matId,matName,store,available,flag,modifyBy);
        return 1;
    }

    @Override
    public int deleteMaterial(String matId) {
        materialMapper.deleteMaterial(matId);
        return 1;
    }
}
